Conversation
AMashoshyna
left a comment
There was a problem hiding this comment.
Nice use of recursion. Please below my comments.
| process.exit(0); | ||
| } | ||
|
|
||
| function getParamsFromArguments () { |
There was a problem hiding this comment.
This function has too much responsibility. Although it is called "getParamsFromArguments", it actually not only gets the parameters, but also processes them. I suggest to split it into several functions.
This might not be a case for this small program, but usually argument parsing is reused and thus should not contain any specific logic.
| }); | ||
| socket.on('timeout', function () { | ||
| socket.destroy(); | ||
| reject(new Error('timeout')); |
There was a problem hiding this comment.
I think that in terms of this program timeout is not an error, but expected behavior for closed port. Your solution is ok, but to me it looks cleaner to resolve the Promise with boolean value (true for open ports and false for closed ports). This way you don't need to have empty catch block.
I've read
./README.mdand./CODE_QUALITY.mdcarefully.The code is checked by npm run lint:js --fix` and linter reported no errors.
The code is submitted in its own sub-directory and in a dedicated feature branch.
Please, review.